package j20251113;

public class Solution2 {
    int[][] memo;
    public int uniquePaths(int m, int n) {
        memo=new int[m+1][n+1];
        return dfs(m,n);
    }
    public int dfs(int i,int j){
        if(memo[i][j]!=0){
            return memo[i][j];
        }
        if(i==0||j==0){
            return 0;
        }
        if(i==1&&j==1){
            memo[i][j]=1;
            return 1;
        }
        memo[i][j]=dfs(i-1,j)+dfs(i,j-1);
        return memo[i][j];
    }
}
